// pulse_controlled_device.h
// 
// Pulse controlled device interface.
// Servos and motor controllers are pulse controlled devices.
// 
// Author: egor.zaitsev@tut.by

#ifndef PULSE_CONTROLLED_DEVICE_H
#define PULSE_CONTROLLED_DEVICE_H

typedef float Pulse_t; // probably it will be replaced by integer value in, say, microseconds or nanoseconds
typedef unsigned char ControlValue_t;

typedef struct
{
    ControlValue_t currentValue;
    ControlValue_t minValue;
    ControlValue_t maxValue;

    Pulse_t period;

    Pulse_t currentPulse;
    Pulse_t minPulse;
    Pulse_t maxPulse;

} PulseControlledDevice_t;

void InitDevice(PulseControlledDevice_t *device,
                ControlValue_t initialValue, ControlValue_t minValue, ControlValue_t maxValue,
                Pulse_t period,
                Pulse_t Pulse_t minPulse, Pulse_t maxPulse);

ControlValue_t GetValue(PulseControlledDevice_t *device);

void SetValue(PulseControlledDevice_t *device, ControlValue_t value);

#endif // PULSE_CONTROLLED_DEVICE_H
